package com.wandian.setting.mvvm.modifypassword;

import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.StatusBarUtils;
import com.mylib.libcore.utils.ToastUtil;
import com.mylib.libcore.utils.UIUtils;
import com.wandian.setting.R;
import com.wandian.setting.databinding.SetActivityModifyPasswordBinding;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description  修改密码
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_SETTING_MODIFY_PASSWORD)
public class ModifyPasswordActivity extends  BaseMVVMActivity<ModifyPasswordViewModel>  {
    private SetActivityModifyPasswordBinding dataBinding;
    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.set_activity_modify_password);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);
        initViewData();
        initClink();
    }
    private void initViewData(){
        //设置状态颜色和字体黑色
        StatusBarUtils.with(this,false)
                .setIsActionBar(false)
                .clearActionBarShadow()
                .setDrawable(getResources().getDrawable(com.mylib.libcore.R.drawable.sys_color))
                .init();
        dataBinding.bindSysToolBar.toolBarTvTitle.setText("修改密码");
    }
    private void initClink(){
        dataBinding.bindSysToolBar.toolBarIvBack.setOnClickListener(v -> {
            finishhideSoftBoard();
            finish();
        });
        dataBinding.tvModifyBtn.setOnClickListener(v -> {
            if(UIUtils.isEmpty(dataBinding.etNewPassword.getText()) || dataBinding.etNewPassword.getText().toString().length()<6){
                ToastUtil.show("请输入6-18位数字或字符");
                return;
            }
            if(UIUtils.isEmpty(dataBinding.etNewPasswordTwo.getText()) || dataBinding.etNewPasswordTwo.getText().toString().length()<6){
                ToastUtil.show("请确认新密码");
                return;
            }
            String nawPassword = dataBinding.etNewPassword.getText().toString();
            String passwordTwo = dataBinding.etNewPasswordTwo.getText().toString();
            if(nawPassword.equals(passwordTwo)){

            }else {
                ToastUtil.show("两次输入的密码不统一");
                return;
            }
        });

    }

}
